package com.bdy.lm.isu.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.bdy.lm.browser.dao.DriverDao;
import com.bdy.lm.common.model.Driver;
import com.bdy.lm.common.model.ISUMesaage;
import com.bdy.lm.common.model.MsgID;
import com.google.gson.Gson;

@Service("isuService")
public class ISUService {

	@Autowired
	private DriverDao driverDao;
	
	@Transactional(readOnly = false)
	public String login(ISUMesaage isuMsg) {
		Driver driver = driverDao.queryDriver(isuMsg.getDriver());
		if (driver != null) {
			isuMsg.setDriver(driver);
			isuMsg.setResultFlag(MsgID.SUCCESS);
		} else {
			isuMsg.setResultFlag(MsgID.FAIL);
		}
		return new Gson().toJson(isuMsg);
	}
}
